<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('审批列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>所属单位：</label>
                                <input type="text" name="purchasingUnitId"/>
                            </li>

                            <li>
                                <label>采购计划：</label>
                                <input type="text" name="purchasePlanId"/>
                            </li>



                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:approve:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:approve:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:approve:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:approve:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:approve:remove')}]];
        var yulanFlag = [[${@permission.hasPermi('system:approve:yulan')}]];
        var prefix = ctx + "system/approve";

        $(function() {
            var options = {
                url: prefix + "/list?cgbApproveResult=0",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "审批",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'approveId',
                    title: '审批表ID',
                    visible: false
                },
                    {
                        field: 'procurementDeclareId',
                        title: '申报表ID',
                        visible: false
                    },
                {
                    field: 'attribute2',
                    title: '项目申报编号'
                },
                    {
                        field: 'sysProcurementdeclare.projectName',
                        title: '项目名称'
                    },
                {
                    field: 'sysProcurementdeclare.unitName',
                    title: '采购单位'
                },
                {
                    field: 'sysProcurementdeclare.contactName',
                    title: '联系人'
                },
                    {
                        field: 'sysProcurementdeclare.mobilePhone',
                        title: '联系人'
                    },
                {
                    field: 'sysProcurementdeclare.tel',
                    title: '固定电话'
                },
                {
                    field: 'sysProcurementdeclare.expectMoney',
                    title: '计划资金（万元）'
                },

                    {
                        field: 'cgbApproveResult',
                        title: '审核状态',
                        formatter: function(value, row, index) {
                            // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                            // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                            if(value=='0'){
                                return "未审批"
                            }else if(value=='1'){
                                return '同意，已审批'
                            }else if(value=='-1'){
                                return "不同意";
                            }else if(value=='-2'){
                                return "作废";
                            }



                        }
                    },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    }
                ,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.cgbApproveResult==0 ||row.cgbApproveResult==-1){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.approveId + '\')"><i class="fa fa-edit"></i>审批</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + yulanFlag + '" href="javascript:void(0)" onclick="yulan(\'' + row.procurementDeclareId + '\')"><i class="fa fa-edit"></i>预览</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /**
         * 申报表预览
         * @param approveId
         */
        function yulan(procurementDeclareId) {
            var url = prefix +'/yulan/' + procurementDeclareId;
            $.modal.open("预览", url, '800', '600');
        }
    </script>
</body>
</html>